package com.lanchetech.user.controller;

import com.lanchetech.bean.request.ActivityBindSpuReq;
import com.lanchetech.bean.request.OrderReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.response.SpuResp;
import com.lanchetech.entity.User;
import com.lanchetech.user.config.ReturnPayInfoVO;
import com.lanchetech.user.service.ActivityService;
import com.lanchetech.user.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 新人专区活动下单
 */
@Api(value = "活动接口", tags = "活动接口")
@RequestMapping("/api/activity")
@RestController
public class ActivityController {

    @Resource
    private ActivityService activityService;
    @Resource
    private OrderService orderService;

    @ApiOperation("新人专区活动下单")
    @PostMapping("/createNewUserOrder")
    public ResultData<ReturnPayInfoVO> createWechatPayOrder(@AuthenticationPrincipal User user,
                                                            @RequestBody OrderReq req,
                                                            HttpServletRequest httpServletRequest) {
        return orderService.createWechatPayOrder(user, req, httpServletRequest);
    }

    @ApiOperation("查看新人活动商品分页列表")
    @PostMapping("/getSpuPage")
    public ResultData<BasePageResp<SpuResp>> getPage(@RequestBody ActivityBindSpuReq req){
        return activityService.getBindPage(req);
    }
}
